<?php

/**
 * 前台 招聘 模块 Controller
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zwt007 $  <zwttmac@qq.com>
 * $Id: page.php 40 2011-07-11 17:15:06Z zwt007 $
 * http://www.t-mac.org；
 */
class hrAction extends Action
{

    private $tmp_model;
    private $show_model;
    private $index_model;

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('comment', 'admin');
        $this->show_model = Tmac::model('show');
        $this->index_model = Tmac::model('index');
        $this->M('index')->getCommon();
    }

    public function index()
    {
        $name = $this->H($this->getParam('name'));
        $name = empty($name) ? 'zhaopin' : $name;
        $catinfo = $this->show_model->getCategoryInfo($name);

        $nicename = $this->index_model->getToptypeNmae($name);
        $sex_array = Tmac::config('hr.sex');
        $hunyin_array = Tmac::config('hr.hunyin');
        $xuanzhe_array = Tmac::config('hr.xuanzhe');       

        $sex_option = Utility::Option($sex_array);
        $hunyin_option = Utility::Option($hunyin_array);
        $xuanzhe_option = Utility::Option($xuanzhe_array);


        $this->assign('nicename', $nicename);
        $this->assign('catinfo', $catinfo);
        $this->assign('name', $name);
        $this->assign('sex_option', $sex_option);
        $this->assign('hunyin_option', $hunyin_option);
        $this->assign('xuanzhe_option', $xuanzhe_option);
        $this->V('hrzhaopin');
    }

    public function save()
    {
        if (empty($_POST) || count($_POST) < 2) {
            $this->redirect('don\'t be evil');
            exit;
        }

        $user_id = intval($this->getParam('user_id'));
        $name = $this->H($this->getParam('name'));
        $sex = intval($this->getParam('sex'));
        $xueli = $this->H($this->getParam('xueli'));
        $jiguan = $this->H($this->getParam('jiguan'));
        $xuexiao = $this->H($this->getParam('xuexiao'));
        $zhuanye = $this->H($this->getParam('zhuanye'));
        $shengri = $this->H($this->getParam('shengri'));
        $hunyin = intval($this->getParam('hunyin'));
        $tel = $this->H($this->getParam('tel'));
        $thumb = $this->H($this->getParam('thumb')); //照片
        $address = $this->H($this->getParam('address')); //通信地址
        $jieshao = $this->H($this->getParam('jieshao')); //自我介绍
        $jingli = $this->H($this->getParam('jingli')); //工作经历
        $yeji = $this->H($this->getParam('yeji')); //原销售业绩
        $gongzi = $this->H($this->getParam('gongzi')); //原工作职务和工资
        $kanfa = $this->H($this->getParam('kanfa')); //对销售工作的看法
        $yingxiang = $this->H($this->getParam('yingxiang')); //对本公司的印象
        $xiwang = $this->H($this->getParam('xiwang')); //对本公司的希望
        $fangxiang = $this->H($this->getParam('fangxiang')); //期望发展方向
        $gongziyaoqiu = $this->H($this->getParam('gongziyaoqiu')); //工资要求
        $daogang = $this->H($this->getParam('daogang')); //到岗时间

        $yb = intval($this->getParam('yb')); //仪表
        $kc = intval($this->getParam('kc')); //口才
        $jy = intval($this->getParam('jy')); //经验
        $zh = intval($this->getParam('zh')); //智慧
        $jq = intval($this->getParam('jq')); //进取
        $yl = intval($this->getParam('yl')); //毅力
        $sf = intval($this->getParam('sf')); //说服
        $cs = intval($this->getParam('cs')); //成熟
        $bf = intval($this->getParam('bf')); //抱负

        $pingyu = $this->H($this->getParam('pingyu')); //评语
        $yijian = $this->H($this->getParam('yijian')); //面试参与人意见
        $miantanyijian = $this->H($this->getParam('miantanyijian')); //主聘面谈人意见

        $content = array(
            'sex' => $sex,
            'xueli' => $xueli,
            'jiguan' => $jiguan,
            'xuexiao' => $xuexiao,
            'zhuanye' => $zhuanye,
            'shengri' => $shengri,
            'hunyin' => $hunyin,
            'jieshao' => $jieshao,
            'jingli' => $jingli,
            'yeji' => $yeji,
            'gongzi' => $gongzi,
            'kanfa' => $kanfa,
            'yingxiang' => $yingxiang,
            'xiwang' => $xiwang,
            'fangxiang' => $fangxiang,
            'gongziyaoqiu' => $gongziyaoqiu,
            'daogang' => $daogang,
            'zhsz' => $zhsz,
            'kc' => $kc,
            'jy' => $jy,
            'zh' => $zh,
            'jq' => $jq,
            'yl' => $yl,
            'sf' => $sf,
            'cs' => $cs,
            'bf' => $bf,
            'pingyu' => $pingyu,
            'yijian' => $yijian,
            'miantanyijian' => $miantanyijian
        );

        //序列化
        $content = serialize($content);

        $info = array(
            'user_id' => $user_id,
            'comment_author' => $name,
            'comment_author_url' => $thumb,
            'comment_time' => time(),
            'comment_content' => $content,
            'comment_author_tel' => $tel,
            'comment_address' => $address,
            'comment_author_ip' => $_SERVER["REMOTE_ADDR"]
        );

//var_dump($info);die;
        //insert save article_class
        $rs = $this->tmp_model->addcomment($info);
        if ($rs) {
            $this->redirect('申请职位成功');
        } else {
            $this->redirect('申请职位失败');
        }
    }

}